/*
 * @Author: lijunqing
 * @Date: 2024-04-17 14:41:24
 * @LastEditors: lijunqing
 * @LastEditTime: 2024-04-17 15:30:11
 * @Description:
 */
const fs = require("fs");

// 1、一次性读取写入文件

// fs.readFile("./ccc.txt", (err, data) => {
//   fs.writeFile("./ddd.txt", data, () => {
//     console.log("写入成功");
//   });
// });

// 2、创建可写可读流

// const crs = fs.createReadStream("./ddd.txt");
// const cws = fs.createWriteStream("./eee.txt");

// crs.on("data", (data) => {
//   console.log(data);

//   cws.write(data);
// });

// 3、可以在可读流和可写流之间建立一个管道

const crs = fs.createReadStream("./ddd.txt");
const cws = fs.createWriteStream("./eee.txt");

crs.pipe(cws);
